﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

using XGameFrame;
using XGameFrame.Controls;

namespace XTowerDef
{
    /// <summary>
    /// A Isometric TileMap
    /// </summary>
    class IsometricTileMap : MapBase
    {
        /// <summary>
        /// Creates a new isometric tilemap
        /// </summary>
        /// <param name="pTileHandler">TileHandler which is to use</param>
        /// <param name="pMapWidht">Optional map widht</param>
        /// <param name="pMapHeight">Optional map height</param>
        public IsometricTileMap(TileHandler pTileHandler, int pMapWidht = 80, int pMapHeight = 80)
            : base(pTileHandler, pMapWidht, pMapHeight)
        {
            SpecializeMap();
        }

        #region Abstract Method Region
        /// <summary>
        /// Do Logic for Map
        /// </summary>
        public override void Update(GameTime pGameTime)
        {
            base.Update(pGameTime);
        }

        /// <summary>
        /// Do drawings for Map
        /// </summary>
        /// <param name="pSpriteBatch">The SpriteBatch from Xna Framework</param>
        public override void Draw(SpriteBatch pSpriteBatch)
        {
            base.Draw(pSpriteBatch);
        }
        /// <summary>
        /// Do Logic if Map is Hovered
        /// </summary>
        /// <param name="pPlayerIndex">The Input from PlayerIndex</param>
        public override void OnHover(PlayerIndex pPlayerIndex)
        {

        }
        /// <summary>
        /// Do Logic for Map if it is Enabled
        /// </summary>
        /// <param name="pPlayerIndex">The Input from PlayerIndex</param>
        public override void HandleInput(PlayerIndex pPlayerIndex)
        {

        }

        #endregion

        #region Method Region
        private void SpecializeMap()
        {
            //Add logic for mapgeneration here

            //for example : 
            //Row[coordY].Column[coordX].AddMultipleFieldIDs(tile,tile1,tile2...tileN);  ** for fields with some layers **
            //or 
            //Row[coordY].Column[coordX].FieldID = tile;  ** for a normal field **

            Row[16].Column[4].AddMultipleHeightFields(54);

            Row[17].Column[3].AddMultipleHeightFields(54);

            Row[15].Column[3].AddMultipleHeightFields(54);
            Row[16].Column[3].AddMultipleHeightFields(53);

            Row[15].Column[4].AddMultipleHeightFields(54, 54, 51);

            Row[18].Column[3].AddMultipleHeightFields(51);
            Row[19].Column[3].AddMultipleHeightFields(50);
            Row[18].Column[4].AddMultipleHeightFields(55);

            Row[14].Column[4].AddMultipleHeightFields(54);

            Row[14].Column[5].AddMultipleHeightFields(62, 61, 63);

            Row[17].Column[4].AddMultipleOverlayFields(114);
            Row[16].Column[5].AddMultipleOverlayFields(115);
            Row[14].Column[4].AddMultipleOverlayFields(125);
            Row[15].Column[5].AddMultipleOverlayFields(91);
            Row[16].Column[6].AddMultipleOverlayFields(94);
        }
        #endregion
    }
}
